package com.xy.bizportdemo.database.entity;

import android.content.ContentValues;
import android.database.Cursor;

/**
 * Created by admin on 2016/11/24.
 */

public class UrlItem {
    private long id;
    private String name;
    private String data;
    private long date;

    public UrlItem() {
        this.date = System.currentTimeMillis();
    }

    public UrlItem setData(String data) {
        this.data = data;
        return this;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public UrlItem setDate(String date) {
        this.date = Long.parseLong(date);
        return this;
    }

    public String getData() {
        return data;
    }

    public long getDate() {
        return this.date;
    }

    public UrlItem(Cursor cursor) {
        this.id = Long.parseLong(cursor.getString(cursor.getColumnIndex(CacheDBTableUrl.KEY_ID)));
        this.data = cursor.getString(cursor.getColumnIndex(CacheDBTableUrl.KEY_DATA));
        this.name = cursor.getString(cursor.getColumnIndex(CacheDBTableUrl.KEY_NAME));
        this.date = Long.parseLong(cursor.getString(cursor.getColumnIndex(CacheDBTableUrl.KEY_DATE)));
    }

    public ContentValues getContentValues() {
        ContentValues values = new ContentValues();

        values.put(CacheDBTableUrl.KEY_NAME, this.name);
        values.put(CacheDBTableUrl.KEY_DATA, this.data);
        values.put(CacheDBTableUrl.KEY_DATE, this.date);

        return values;
    }
}
